import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import jade.core.Agent;
import jade.core.behaviours.DataStore;
import jade.domain.DFService;
import jade.domain.FIPAException;
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAAgentManagement.ServiceDescription;
import jade.domain.introspection.ACLMessage;
import jade.lang.acl.MessageTemplate;
import jade.proto.states.MsgReceiver;


public class CuratorAgent extends Agent {
	ArrayList<Artifact> museum = new ArrayList<Artifact>();
	protected void setup()
	{
		Object[] args = getArguments();
		
		if (args!= null && args.length == 1)
		{
			placeArtifacts((String)args[0]);
		}
		else
		{	
			JOptionPane.showMessageDialog(new JFrame(),
				    "Number of Arguments was wrong, think of defining the museum as an argument. Agent terminates.",
				    "Museum error",
				    JOptionPane.ERROR_MESSAGE);
			System.exit(0);
		}
		
		//TODO
		DFAgentDescription dfd = new DFAgentDescription();
		dfd.setName( getAID() );
		ServiceDescription sd = new ServiceDescription();
		sd.setType( "Museum" );
		sd.setName( getLocalName() );
		dfd.addServices(sd);
		
		try
		{
			DFService.register(this, dfd);
		}
		catch ( FIPAException fe)
		{
			fe.printStackTrace();
		}
	}
	/*
	 * This method should read the file from the specific filename and load this as Artifacts
	 * If there is no file with the name museumName an error message should be displayed (something similar to the one in the setup method)
	 */
	void placeArtifacts(String museumName)
	{
		//TODO
	}
	
	
	class ReceiveAvailableArtifactsQuestions extends MsgReceiver
	{
		public ReceiveAvailableArtifactsQuestions( Agent a, MessageTemplate mt ){ super(a, mt, MsgReceiver.INFINITE, new DataStore(), "Key"); }
		
		protected void handleMessage(ACLMessage msg)
		{
			//TODO
			//This method should send Information back about one Artifact
		}
	}
}
